package ejb.entities;

import java.io.Serializable;
import javax.persistence.*;

/**
 * Entity implementation class for Entity: User
 *
 */
@Entity
@Table(name = "users")
public class User implements Serializable{

@Id
private String username;

//@Column(unique = true)
private String name;
private String surname;
private String job;
private String description;
private String password;
private String email;
private String phone;

private String groupname;
  
    /**
     * Public default empty constructor
     */
    public User() {
}

//GETTER Functions

    /**
     * Returns Entity's primary key Username
     * @return
     */
    
    public String getUsername() {
        return username;
    }

    /**
     * Returns Name of the user
     * @return
     */
    public String getName() {
        return name;
    }

    /**
     * Returns Surname of the user
     * @return
     */
    public String getSurname() {
        return surname;
    }

    /**
     * Returns Job of the users
     * This fiels can be useful with a better integration between information of the users and the service provided by
     * Event manager
     * @return
     */
    public String getJob() {
        return job;
    }

    /**
     * Returns a little description rappresents the user
     * @return
     */
    public String getDescription() {
        return description;
    }

    /**
     * Returns the password stored Encrypted directly to the database
     * @return
     */
    public String getPassword() {
        return password;
    }

    /**
     * Returns the email of the user
     * @return
     */
    public String getEmail() {
        return email;
    }

    /**
     * Returns the email of the user
     * @return
     */
    public String getPhone() {
        return phone;
    }

    /**
     * Return the GROUPNAME of the user
     * This field is always USER beacause in meteocal there aren't administrator user
     * @return
     */
    public String getGroupname() {
        return groupname;
    }

//SETTER Functions

    /**
     *
     * @param username
     */
    
    public void setUsername(String username) {
        this.username = username;
    }

    /**
     *
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     *
     * @param surname
     */
    public void setSurname(String surname) {
        this.surname = surname;
    }

    /**
     *
     * @param job
     */
    public void setJob(String job) {
        this.job = job;
    }

    /**
     *
     * @param description
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     *
     * @param password
     */
    public void setPassword(String password) {
        this.password=password;
    }
   
    /**
     *
     * @param email
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     *
     * @param phone
     */
    public void setPhone(String phone) {
        this.phone = phone;
    }

    /**
     *
     * @param groupname
     */
    public void setGroupname(String groupname) {
        this.groupname = groupname;
    }



//CAST Functions

    /**
     * Returns the concatenation of Name and Surname of the users
     * @return
     */
    public String getFullName() {
	if (this.name != null && this.surname != null)
		return this.name + " " + this.surname + " [" + this.username + "]";
	else
            return this.username;
}

}


